﻿<UserControl x:Class="Deployment.Data.UI.Controls.Connection.ConnectionEditorControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:connections="clr-namespace:Deployment.Data.Environment.Connection;assembly=Deployment.Data"
             xmlns:environments="clr-namespace:Deployment.Data.Environment;assembly=Deployment.Data"
             xmlns:converters="clr-namespace:Deployment.Data.UI.Converters"
             mc:Ignorable="d" 
             x:Name="EditorControl"
             d:DesignHeight="300" d:DesignWidth="300" DataContextChanged="EditorControl_DataContextChanged">
    <UserControl.Resources>
        <ObjectDataProvider x:Key="comboDataSource"
                            ObjectType="{x:Type connections:AbstractConnection}"
                            MethodName="GetAvailableConnectionTypes"/>
        <converters:ObjectToAbstractConnectionControl x:Key="ObjToControl"/>
    </UserControl.Resources>
    <StackPanel Orientation="Vertical" Margin="8">
        <Label Content="Select connection type:"/>
        <ComboBox x:Name="cbo_ConnectionType"
                  ItemsSource="{Binding Source={StaticResource comboDataSource}}"
                  SelectionChanged="cbo_ConnectionType_SelectionChanged"
                  DisplayMemberPath="TypeDescription"
                  SelectedValue="{Binding ElementName=EditorControl, Mode=TwoWay, Path=DataContext}"/>
        <GroupBox Header="Connection Info">
            <StackPanel Orientation="Vertical">
                <Label Content="Connection name:"/>
                <ComboBox Text="{Binding Path=Name}" 
                          IsEditable="True"
                          Margin="4,0,4,2"
                          x:Name="cbo_ConnectionName"
                          />
                <!--<TextBox Text="{Binding Path=Name}"/>-->

                <GroupBox Header="Connection Specific Details" Margin="4" 
                          Content="{Binding ElementName=cbo_ConnectionType, Path=SelectedItem, Converter={StaticResource ObjToControl}, ConverterParameter='No Connection Type Selected...'}">
                    <!--<StackPanel Orientation="Vertical" x:Name="stk_Details" Margin="2">
                        <Label Content="Please select a connection type." MinWidth="300"/>
                    </StackPanel>-->
                </GroupBox>
            </StackPanel>
        </GroupBox>
    </StackPanel>
</UserControl>
